package com.hospital.controller;

import com.hospital.constant.MessageConstant;
import com.hospital.dto.HospitalizationRecordDTO;
import com.hospital.result.PageResult;
import com.hospital.result.Result;
import com.hospital.service.HospitalizationRecordService;
import com.hospital.vo.AdmissionTrendVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/hospitalizationRecord")
@Slf4j
@Api(tags = "3.入院信息管理")
public class HospitalizationRecordController {
    @Autowired
    private HospitalizationRecordService hospitalizationRecordService;

    @GetMapping("/admission")
    @ApiOperation("分页查询入院信息")
    public Result<PageResult> getHospitalizationRecordList(HospitalizationRecordDTO hospitalizationRecordDTO) {
        log.info("入院记录分页查询参数: {}", hospitalizationRecordDTO);
        PageResult pageResult = hospitalizationRecordService.pageQueryAdmission(hospitalizationRecordDTO);
        return Result.success(pageResult, MessageConstant.QUERY_SUCCESS);
    }

    @GetMapping("/discharge")
    @ApiOperation("分页查询出院信息")
    public Result<PageResult> getDischargeRecordList(HospitalizationRecordDTO hospitalizationRecordDTO) {
        log.info("出院记录分页查询参数: {}", hospitalizationRecordDTO);
        PageResult pageResult = hospitalizationRecordService.pageQueryDischarge(hospitalizationRecordDTO);
        return Result.success(pageResult, MessageConstant.QUERY_SUCCESS);
    }

    @GetMapping("/getAdmissionTrend")
    @ApiOperation("获取入院趋势")
    public Result<List<AdmissionTrendVO>> getAdmissionTrend() {
        log.info("获取入院趋势");
        List<AdmissionTrendVO> admissionTrendVOList = hospitalizationRecordService.getAdmissionTrend();
        return Result.success(admissionTrendVOList, MessageConstant.QUERY_SUCCESS);
    }
}
